package com.heima.admin.controller.v1;

import com.heima.admin.service.AdSensitiveService;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.dtos.SensitiveDTO;
import com.heima.model.common.pojos.AdSensitive;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 29143
 */
@Api(value = "敏感词管理API",tags = "敏感词管理API")
@RestController
@RequestMapping("/api/v1/sensitive")
public class AdSensitiveController {

    @Autowired
    private AdSensitiveService adSensitiveService;

    /**
     * 分页模糊查询敏感词
     * @param sensitiveDTO
     * @return
     */
    @ApiOperation(value = "查询敏感词")
    @PostMapping("/list")
    public ResponseResult list (@RequestBody SensitiveDTO sensitiveDTO){
        return adSensitiveService.list(sensitiveDTO);
    }

    /**
     * 添加敏感词
     * @param adSensitive
     * @return
     */
    @ApiOperation(value = "添加敏感词")
    @PostMapping("/save")
    public ResponseResult add(@RequestBody AdSensitive adSensitive){
        return adSensitiveService.add(adSensitive);
    }

    /**
     * 修改敏感词
     * @param adSensitive
     * @return
     */
    @ApiOperation(value = "修改敏感词")
    @PostMapping("/update")
    public ResponseResult update(@RequestBody AdSensitive adSensitive){
        return adSensitiveService.update(adSensitive);
    }

    /**
     * 删除敏感词
     * @param id
     * @return
     */
    @ApiOperation(value = "删除敏感词")
    @DeleteMapping("/del/{id}")
    public ResponseResult delete(@PathVariable Integer id){
        return adSensitiveService.delete(id);
    }

    /**
     * 查询敏感词内容列表
     * @return
     */
    @ApiOperation(value = "查询敏感词内容list")
    @PostMapping("/sensitives")
    public ResponseResult sensitives() {
        return adSensitiveService.selectAllSensitives();
    }
}
